package com.csc.yunting.service.sms.config;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;

//@Configuration  此注解标注的配置类  项目启动时一定会初始化对象添加到容器中
@ConfigurationProperties(prefix = "aliyun.sms")
@Data
public class SmsProperties implements InitializingBean {
    private String host;// = "https://smsv2.market.alicloudapi.com";
    //资源路径
    private String path;// = "/sms/sendv2";
    //请求方式
    private String method;// = "GET";
    //在短信平台购买短信服务时的 唯一id
    private String appcode;// = "8e45699f00ff4bdbb807664045acd813";

    public static String HOST;
    public static String PATH;
    public static String METHOD;
    public static String APPCODE;
    //对象初始化后调用
    @Override
    public void afterPropertiesSet() throws Exception {
        SmsProperties.HOST = this.host;
        SmsProperties.PATH = this.path;
        SmsProperties.METHOD = this.method;
        SmsProperties.APPCODE = this.appcode;
    }
}
